package net.xiduth.game.player.dialogues.auto;

import net.xiduth.game.World;
import net.xiduth.game.player.Player;
import net.xiduth.game.player.dialogues.Dialogue;

/**
 * 
 * @author Oracle
 * 
 * Handles PvM Rewards and info.
 *
 */
public class Page2PvM extends Dialogue {


	@Override
	public void start() {
		sendOptionsDialogue("PvM Rewards - Page 2", "50x Construction package (25 pts.)", "50x Steel nails (25 pts.)", "50x Mahogany planks (30 pts.)" , "250x Stardust (200 pts.)", "Next page...");
		stage = 4;
	}

	@Override
	public void run(int interfaceId, int option) {
		switch(stage) {
		case -1:
			sendOptionsDialogue("Select an Option", "How many points do I have?", "I would like to exchange my points.", "How do I get points?", "I would like to access my bank account.", "Never mind.");
			stage = 0;
			break;
		case 0:
			switch(option) {
			case OPTION_1:
				sendDialogue("You currently have " + player.getPvMPoints() + " points.");
				stage = -1;
				break;
			case OPTION_2:
				sendOptionsDialogue("PvM Rewards - Page 2", "50x Construction package (25 pts.)", "50x Steel nails (25 pts.)", "50x Mahogany planks (30 pts.)" , "250x Stardust (200 pts.)", "Never mind.");
				stage = 4;
				break;
			case OPTION_3:
				sendDialogue("Each monster you kill will give you up to 5 PvM Points, the points can then be exchanged here.");
				stage = -1;
				break;
			case OPTION_4:
				player.getBank().openBank();
				player.getInterfaceManager().closeChatBoxInterface();
				break;
			case OPTION_5:
				player.getDialogueManager().startDialogue("Page3PvM");
				break;
			}
			break;
		case 3:
			end();
			break;
		case 4:
			switch(option) {
		case OPTION_1: //960 planks
				if (player.getPvMPoints() >= 25) {
				player.getBank().addItem(8786, 50, true);
				player.getBank().addItem(3420, 50, true);
				player.getBank().addItem(960, 50, true);
				player.getBank().addItem(1761, 50, true);
				player.setPvMPoints(player.getPvMPoints()
						- 25);
				player.getInterfaceManager().closeChatBoxInterface();
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 960, 1);
				player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
				stage = 3;
				}else{
				sendDialogue("You need 25 points to buy this item." );
				stage = 3;
				}
				break;
		case OPTION_2: //1539 steel nails
			if (player.getPvMPoints() >= 25) {
			player.getBank().addItem(1539, 50, true);
			player.setPvMPoints(player.getPvMPoints()
					- 25);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 1539, 1);
			player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
			stage = 3;
			}else{
			sendDialogue("You need 25 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_3: //8782 mahogany planks
			if (player.getPvMPoints() >= 30) {
			player.getBank().addItem(8782, 50, true);
			player.setPvMPoints(player.getPvMPoints()
					- 30);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 8782, 1);
			player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
			stage = 3;
			}else{
			sendDialogue("You need 30 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_4: //13727 stardust (125x)
			if (player.getPvMPoints() >= 500) {
			player.getBank().addItem(13727, 500, true);
			player.setPvMPoints(player.getPvMPoints()
					- 500);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 13727, 1);
			player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
			player.sm("Purchase complete.");
			/* for (Player players : Engine.getPlayers()) {
				if (players == null)
					continue;
				players.getPackets()
						.sendGameMessage(
								"<col=ff8c38><img=7>[PvM Rewards]: "
										+ player.getDisplayName()
										+ " has obtained 500x Stardust."); } */
			stage = 3;
			}else{
			sendDialogue("You need 200 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_5:
			player.getDialogueManager().startDialogue("Page3PvM");
			break;
		case 5:
			switch(option) {
		case OPTION_1: //6746 darklight
				if (player.getPvMPoints() >= 500) {
				player.getBank().addItem(6746, 1, true);
				player.setPvMPoints(player.getPvMPoints()
						- 500);
				player.getInterfaceManager().closeChatBoxInterface();
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 6746, 1);
				player.getPackets().sendIComponentText(1189, 4, "The item has been added to your bank.");
				for (Player players : World.getPlayers()) {
					if (players == null)
						continue;
					players.getPackets()
							.sendGameMessage(
									"<col=ff8c38><img=7>[PvM Rewards]: "
											+ player.getDisplayName()
											+ " has obtained a Darklight."); }
				stage = 3;
				}else{
				sendDialogue("You need 500 points to buy this item." );
				stage = 3;
				}
				break;
		case OPTION_2: //14484 - dragon claws
			if (player.getPvMPoints() >= 3500) {
			player.getBank().addItem(14484, 1, true);
			player.setPvMPoints(player.getPvMPoints()
					- 3500);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 14484, 1);
			player.getPackets().sendIComponentText(1189, 4, "The item has been added to your bank.");
			for (Player players : World.getPlayers()) {
				if (players == null)
					continue;
				players.getPackets()
						.sendGameMessage(
								"<col=ff8c38><img=7>[PvM Rewards]: "
										+ player.getDisplayName()
										+ " has obtained Dragon claws."); }
			stage = 3;
			}else{
			sendDialogue("You need 3,500 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_3: //15332 overload bundle
			if (player.getPvMPoints() >= 100) {
			player.getBank().addItem(15332, 25, true);
			player.setPvMPoints(player.getPvMPoints()
					- 100);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 15332, 1);
			player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
			for (Player players : World.getPlayers()) {
				if (players == null)
					continue;
				players.getPackets()
						.sendGameMessage(
								"<col=ff8c38><img=7>[PvM Rewards]: "
										+ player.getDisplayName()
										+ " has obtained an overload bundle."); }
			stage = 3;
			}else{
			sendDialogue("You need 100 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_4: //13727 stardust (125x)
			if (player.getPvMPoints() >= 100) {
			player.getBank().addItem(13727, 125, true);
			player.setPvMPoints(player.getPvMPoints()
					- 100);
			player.getInterfaceManager().closeChatBoxInterface();
			player.getInterfaceManager().sendChatBoxInterface(1189);
			player.getPackets().sendItemOnIComponent(1189, 1, 13727, 1);
			player.getPackets().sendIComponentText(1189, 4, "The items have been added to your bank.");
			for (Player players : World.getPlayers()) {
				if (players == null)
					continue;
				players.getPackets()
						.sendGameMessage(
								"<col=ff8c38><img=7>[PvM Rewards]: "
										+ player.getDisplayName()
										+ " has obtained 125x Stardust."); }
			stage = 3;
			}else{
			sendDialogue("You need 100 points to buy this item." );
			stage = 3;
			}
			break;
		case OPTION_5:
			player.getDialogueManager().startDialogue("Page3PvM");
			//sendOptionsDialogue("PvM Rewards - Page 2", "50x Planks (25 pts.)", "50x Steel nails (25 pts.)", "50x Mahogany planks (30 pts.)" , "250x Stardust (200 pts.)", "Never mind.");
			//stage = 5;
			break;
		case 69:
			player.getControlerManager().startControler("DarkInvasion");
			break;
		default:
			end();
			break;
		}}}}

	@Override
	public void finish() {

	}

}
